package com.example.sunmiv1.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.sunmiv1.R;
import com.example.sunmiv1.entity.RepaymentRecordInfo;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class RepaymentRecordAdapter extends BaseAdapter {


    private List<RepaymentRecordInfo.DataBean.ListBean> list;
    private ViewHolder viewHolder;

    public RepaymentRecordAdapter(List<RepaymentRecordInfo.DataBean.ListBean> list) {
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_repayment_record, null);
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        RepaymentRecordInfo.DataBean.ListBean bean = list.get(position);
        viewHolder.itemRepaymentRecordOrderNo.setText(bean.getOrder_no());
        viewHolder.itemRepaymentRecordCreditTime.setText(bean.getArrearage_time());
        viewHolder.itemRepaymentRecordCreditMoney.setText(bean.getBill_money());
        viewHolder.itemRepaymentRecordCreditUser.setText(bean.getArrearage_name());
        viewHolder.itemRepaymentRecordRepayTime.setText(bean.getEdit_time());
        viewHolder.itemRepaymentRecordRepayType.setText(bean.getPay_type_name());
        viewHolder.itemRepaymentRecordRepayMoney.setText(bean.getMoney());
        viewHolder.itemRepaymentRecordRepayUser.setText(bean.getRepayment_name());
        viewHolder.itemRepaymentRecordRepaidMoney.setText(bean.getRepayment_money());
        return convertView;
    }

    static class ViewHolder {
        @BindView(R.id.itemRepaymentRecord_orderNo)
        TextView itemRepaymentRecordOrderNo;
        @BindView(R.id.itemRepaymentRecord_creditMoney)
        TextView itemRepaymentRecordCreditMoney;
        @BindView(R.id.itemRepaymentRecord_creditTime)
        TextView itemRepaymentRecordCreditTime;
        @BindView(R.id.itemRepaymentRecord_creditUser)
        TextView itemRepaymentRecordCreditUser;
        @BindView(R.id.itemRepaymentRecord_repayTime)
        TextView itemRepaymentRecordRepayTime;
        @BindView(R.id.itemRepaymentRecord_repayType)
        TextView itemRepaymentRecordRepayType;
        @BindView(R.id.itemRepaymentRecord_repayMoney)
        TextView itemRepaymentRecordRepayMoney;
        @BindView(R.id.itemRepaymentRecord_repayUser)
        TextView itemRepaymentRecordRepayUser;
        @BindView(R.id.itemRepaymentRecord_repaidMoney)
        TextView itemRepaymentRecordRepaidMoney;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
